package com.ruoyi.qsng.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.SnowFlakeUtil;
import com.ruoyi.qsng.domain.KCarouselFigure;
import com.ruoyi.qsng.mapper.KCarouselFigureMapper;
import com.ruoyi.qsng.service.IKCarouselFigureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 轮播图片Service业务层处理
 *
 * @author kanglou
 * @date 2023-06-07
 */
@Service
public class KCarouselFigureServiceImpl implements IKCarouselFigureService {
    @Autowired
    private KCarouselFigureMapper kCarouselFigureMapper;

    /**
     * 查询轮播图片
     *
     * @param id 轮播图片主键
     * @return 轮播图片
     */
    @Override
    public KCarouselFigure selectKCarouselFigureById(String id) {
        return kCarouselFigureMapper.selectKCarouselFigureById(id);
    }

    /**
     * 查询轮播图片列表
     *
     * @param kCarouselFigure 轮播图片
     * @return 轮播图片
     */
    @Override
    public List<KCarouselFigure> selectKCarouselFigureList(KCarouselFigure kCarouselFigure) {
        return kCarouselFigureMapper.selectKCarouselFigureList(kCarouselFigure);
    }

    /**
     * 新增轮播图片
     *
     * @param kCarouselFigure 轮播图片
     * @return 结果
     */
    @Override
    public int insertKCarouselFigure(KCarouselFigure kCarouselFigure) {
        kCarouselFigure.setId(SnowFlakeUtil.getNextId());
        kCarouselFigure.setCreateTime(DateUtils.getNowDate());
        return kCarouselFigureMapper.insertKCarouselFigure(kCarouselFigure);
    }

    /**
     * 修改轮播图片
     *
     * @param kCarouselFigure 轮播图片
     * @return 结果
     */
    @Override
    public int updateKCarouselFigure(KCarouselFigure kCarouselFigure) {
        kCarouselFigure.setUpdateTime(DateUtils.getNowDate());
        return kCarouselFigureMapper.updateKCarouselFigure(kCarouselFigure);
    }

    /**
     * 批量删除轮播图片
     *
     * @param ids 需要删除的轮播图片主键
     * @return 结果
     */
    @Override
    public int deleteKCarouselFigureByIds(String[] ids) {
        return kCarouselFigureMapper.deleteKCarouselFigureByIds(ids);
    }

    /**
     * 删除轮播图片信息
     *
     * @param id 轮播图片主键
     * @return 结果
     */
    @Override
    public int deleteKCarouselFigureById(String id) {
        return kCarouselFigureMapper.deleteKCarouselFigureById(id);
    }
}
